package com.leyou.httpdemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class HttpDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(HttpDemoApplication.class, args);
	}


//	restTemplate直接声明没有任何参数时，底层实现用的是JDK的URLconnect，如果需要改变，可以在构造器中传入对应的工厂对象
	 @Bean
	public RestTemplate restTemplate() {
//		此时有参数，使用OKhttp作为底层实现
		return new RestTemplate(new OkHttp3ClientHttpRequestFactory());
	}
}
